package com.yxy.chatserver.mapper;

import com.yxy.chatserver.domain.po.FriendRequest;
import com.yxy.chatserver.domain.vo.FriendRequestVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

/**
 *  friend Mapper
 */
@Mapper
public interface FriendMapper {

    /**
     * 根据fromUserId和toUserId查询
     * @param fromUserId
     * @param toUserId
     * @return
     */
    @Select("select * from friend_request where fromUserId = #{fromUserId} and toUserId = #{toUserId} limit 1")
    FriendRequestVO findByFromUserIdAndToUserId(String fromUserId, String toUserId);

    /**
     * 添加好友申请
     * @param newFriendRequestVO
     */
    void addFriendRequest(FriendRequest newFriendRequest);

    /**
     * 更新好友申请状态
     * @param fromUserId
     * @param toUserId
     * @param status
     * @param sendTime
     */
    void updateFriendRequestStatus(String fromUserId, String toUserId, String status, LocalDateTime sendTime);
}
